/*  
 * @(#) PageBean.java Create on 2012-5-8 下午4:15:51   
 *   
 * Copyright 2012 by xl.   
 */

package cn.com.common.base.bean;

import java.util.Collections;
import java.util.List;

import cn.com.common.Constants;

/**
 * 
 * @author zhanghongliang
 * @date 2012-5-8
 */
public class PageBean<T> {
	/**
	 * 默认设定每页显示记录数为10
	 */
	public static final int DEFAULT_PAGE_SIZE = Constants.DEFAULT_PAGE_SIZE;
	
	private List<T> rows;
	private int pageNow;
	private int pageSize;
	private int pageCount;
	private int total;

	public List<T> getRows() {
		return rows == null ? Collections.<T> emptyList() : this.rows;
	}

	public void setRows(List<T> rows) {
		this.rows = rows;
	}

	public int getPageNow() {
		return pageNow;
	}

	public void setPageNow(int pageNow) {
		this.pageNow = pageNow;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageCount() {
		if(pageSize==0){
			return 0;
		}
		return (total + pageSize - 1) / pageSize;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}
}
